import { PRIORITY_VIEW } from "../../../Core/CoreDefine";
import { GCtrl } from "../../../Core/GCtrl";
import GViewBase from "../../../Core/GView/GViewBase";
import { CMsg, RPointMask, SPECIALWINDOW, VIPBOXTYPE, VIPRECEIVE } from "../../Common/Define";
import { VIEW_ID } from "../../Common/UI";
import { Res } from "../../Common/UIResources";
import FriendItem from "../../Item/FriendItem";
import GameMgr from "../../Logic/GameMgr";
import HangPage from "../Common/HangPage";
import TopUiItem from "../Common/TopUiItem";
import VipPage from "./VipPage";


const { ccclass, property, menu, executeInEditMode } = cc._decorator;
@ccclass @menu('View/Home/EmailView')

export default class EmailView extends GViewBase {

    @property({type: cc.Node, tooltip: "底部按钮模块1"})  to1Btn: cc.Node = null;

    @property({type: cc.Node, tooltip: "底部按钮模块2"})  to2Btn: cc.Node = null;

    @property({type: cc.Node, tooltip: "底部按钮模块3"})  to3Btn: cc.Node = null;

    @property({type: cc.Node, tooltip: "推荐模块"})  tuijianNode: cc.Node = null;

    @property({type: cc.Node, tooltip: "列表父类"})  listContent: cc.Node = null;

    selectTog:number = 1;


    onGLoad() {
        this.addHang();
        // this.refresh();
    }

    public addHang() {
            /**顶部UI */
            var self = this;
            this.addGChild<TopUiItem>(Res.prefab.item.topUiItem, (comp: TopUiItem) => {
                //comp.node.parent = GameMgr.uiMgr.uiRoot;
                comp.node.parent = self.bgImage.node;
                let winSize = cc.winSize;
                // comp.node.setPosition(cc.v2(-winSize.width / 2, winSize.height / 2));
                comp.setModeType(1, "邮件")
                comp.node.setPosition(cc.v2(-winSize.width / 370, winSize.height / 2.16));
            });
    }

    refresh(){
        this.to1Btn.active = this.selectTog == 1;

        this.to2Btn.active = this.selectTog == 2;

        this.to3Btn.active = this.selectTog == 3;

        this.tuijianNode.active = this.selectTog == 3;

        for (let index = 0; index < this.listContent.children.length; index++) {
            const element = this.listContent.children[index];
            element.getComponent(FriendItem).setView(this.selectTog);
        }
    }


    close() {
        this.onClose();
    }

    onClickHanlder(event:Event, str:string){
        if (str == "tog1"){
            this.selectTog = 1
            this.refresh();
        }
        else if (str == "tog2"){
            this.selectTog = 2
            this.refresh();
        }
        else if (str == "tog3"){
            this.selectTog = 3
            this.refresh();
        }
        else if (str == "ruleBtn"){
            GameMgr.jumpToMgr.jumpGoTo(VIEW_ID.comonTipView, 4);
        }
    }
}